<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">

<head>
<title>js第2课-a链接</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="这是js第2课-a链接">
<style type="text/css">
#div1 {
	width: 100px;
	height: 100px;
	border: 1px solid black;
}

.box {
	background: red;
}
</style>
<script type="text/javascript">
	function toRed() {
		var div1 = document.getElementById("div1");
		// div1.class = "box";
		div1.className = "box";
	}
</script>

</head>

<body>
	<a href="javascript:alert('a')">链接</a>
	<input type="button" value="变红" onclick="toRed()">
	<div id="div1"></div>
</body>

</html>